package com.java0106;

public class Test03 {
    public static void main(String[] args) {
        //字符串类
        String s = "abcdefg";
        String s2 = "nihaoa";
        //查找
        int i = s.indexOf("s");//返回下标，没有返回-1
        System.out.println(i);

        //截取
        String substring = s.substring(0, 3);//左闭右开
        System.out.println(substring);

        String substring1 = s.substring(2, 3);//左闭右开
        System.out.println(substring1);
        String substring2 = s.substring(1,2);//左闭右开
        System.out.println(substring2);
        //长度length()
        int length = s.length();
        System.out.println(length);

        int length1 = s2.length();
        System.out.println(length1);



        //去空格
        String s1 = "  xgy   ";
        String trim = s1.trim();
        System.out.println(trim);

        //替换
        String replace = s1.replace("xgy", "徐国洋");
        System.out.println(replace);

        String replace1 = s.replace("e", "d");
        System.out.println(replace1);

        String replace2 = s.replace("d", "e");
        System.out.println(replace2);

        //根据下标查元素 charAt
        char c = s.charAt(0);
        System.out.println(c);

        char d = s.charAt(2);
        System.out.println(c);

        char e = s.charAt(3);
        System.out.println(e);

    }
}
